package com.sinosoft.ebusiness.util;

import com.bugull.mongo.BuguConnection;
import com.bugull.mongo.BuguDao;
import com.bugull.mongo.BuguFramework;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class MongoUtils {

    static Logger logger = LoggerFactory.getLogger(MongoUtils.class);

    public static BuguConnection getConnection(){
        BuguConnection conn = BuguFramework.getInstance().createConnection();
        return conn;
    }


    static Map<String,Object> map = new HashMap<String,Object>(24);

    public static void addBuguDao(String key ,Object obj){
        if(obj instanceof BuguDao){
            System.out.println("MongoUtils put  key :{}"+key);
            map.put(key,obj);
        }else{
            System.out.println("MongoUtils put  key error  :{}"+key);
        }
    }

    public static  <T> T getDap(String key){
        return (T) map.get(key);
    }
}
